package com.yitiao.data_algorithms.leetcode.editor.cn;

class PowerOfFour {
    // 2023-05-14 22:49:46
    public static void main(String[] args) {
        Solution solution = new PowerOfFour().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public boolean isPowerOfFour(int n) {
            /**
             * 取模运算的一些性质
             * (a + b) % p = (a % p + b % p) % p
             * (a - b) % p = (a % p - b % p) % p
             * (a * b) % p = (a % p * b % p) % p
             *  a ^ b % p = ((a % p)^b) % p
             * ((a +b)% p * c) % p = ((a * c) % p + (b * c) % p) % p
             */
            return (n > 0) && ((n & (n-1)) == 0) && (n % 3 == 1);
        }

        private boolean extracted(int n) {
            while (n != 0 && n % 4 == 0) {
                n = n / 4;
            }
            return n == 1;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}